package com.yeyks.base;

import com.google.common.base.MoreObjects;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author fuchangshuai
 * @time 2019/02/22
 */
@Data
public class PageInfo {
    public static final String LIMIT = "limit";
    public static final String OFFSET = "offset";
    private Integer offset;
    private Integer limit;

    public static PageInfo of(Integer pageNo, Integer pageSize) {
        return new PageInfo(pageNo, pageSize);
    }

    private PageInfo(Integer pageNo, Integer pageSize) {
        if (null == pageNo || pageNo <= 0) {
            pageNo = 1;
        }
        if (pageSize == null || pageSize <= 0) {
            pageSize = 10;
        }
        this.limit = pageSize;
        this.offset = (pageNo - 1) * pageSize;
    }
}
